package graphicswithsomebackup;
import sun.audio.*;
import java.io.*;
import javax.sound.midi.MidiSystem; //midi-ljud
import javax.sound.midi.Sequence; //midi-ljud
import javax.sound.midi.Sequencer; //midi-ljud
/**
 *
 * @author Martin Wilhelmsson
 */
public class Sounds {

    AudioStream as;
    InputStream in;
    AudioStream as2;
    InputStream in2;
    AudioStream as3;
    InputStream in3;


    //source: http://www.java-tips.org/java-se-tips/javax.sound.midi/how-to-load-and-play-midi-audio.html
    public void playMusic() {

        try {
            // From file
            Sequence sequence = MidiSystem.getSequence(new File("sounds/3top.mid"));

            // From URL
            //sequence = MidiSystem.getSequence(new URL("http://home2.swipnet.se/~w-22134/nmm/3top.mid"));

            // Create a sequencer for the sequence
            Sequencer sequencer = MidiSystem.getSequencer();
            sequencer.open();
            sequencer.setSequence(sequence);

            // Start playing
            sequencer.start();
            sequencer.setLoopCount(5);
        }
        catch (Exception e) {
            System.out.println("Detta blev massa fel"+e);
        }




        //--------------------för wav-filer typ!
        /*try
	{
		in = new FileInputStream("godwar.mp3");
		as = new AudioStream(in);
	}
	catch(Exception ea)
	{
		System.out.println(ea.toString());

        }
        AudioPlayer.player.start(as);*/



        //ContinuousAudioDataStream loop = null; //spelar om och om igen

        /*try {
         streamer = new AudioStream(new FileInputStream("namn o var filen ligger"));
         MD = streamer.getData();
         loop = new ContinuousAudioDataStream(MD); //loopar musiken
        }
        catch (Exception e) {
            System.out.println(e + " wtf?");
        }
        player.start(loop);*/
    }
}
